<div id="content">
	<div class="row s_page_title">
		<sa-big-breadcrumbs [items]="['日志信息管理','设备事件']" icon="fa fa-tag" class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
		</sa-big-breadcrumbs>
	</div>
	<sa-widgets-grid>
		<div class="s_table">
			<div sa-widget [editbutton]="false" color="darken" class="clearfix">
				<header><span class="widget-icon"> <i class="fa fa-table"></i> </span>
					<h2>设备事件</h2>
				</header>
				<div>
					<div class="widget-body no-padding">
						<div class="page-header clearfix s_table_opreation">
							<div class="left page-header-btn">
								<div class="top_module top_module_box">
									<span class="module_text">车牌号码</span>
									<div class="s_hover_box">
										<select class="select2" id="carNumberSelect2">
											<option value=''></option>
										</select>
										<div class="s_del_icon" (click)='del_carNumber()'>x</div>
									</div>
								</div>
								<div class="top_module top_module_box">
									<span class="top_module_label module_text">事件类型
									</span><select class="top_module_select select2" id="tcarTypeSelect2"
										name="carUseType" select2>
										<option value="">全部</option>
										<optgroup *ngFor="let item of event" [label]="item.label">
											<option *ngFor="let lis of item.children" [value]='lis.id'>{{lis.label}}
											</option>
										</optgroup>
									</select>
								</div>
								<div class="top_module top_module_box">
									<span class="module_text">操作人</span>
									<input type="text" class="module_inp top_module_select" [(ngModel)]="userName"
										placeholder="操作人" />
								</div>
								<div class="selectDate top_module">
									<table-select-date (outerTime)="dateSelect($event)"></table-select-date>
								</div>
								<!-- <sa-company-tree-car  companyTreeId="companyTree" wrapId="content" [isShowCarSort]="false"  [isShowCarNum]="true"  (companySelected)="companySelected($event)"></sa-company-tree-car> -->
								<button type="button" class="btn btn-primary" (click)="tableSearch()">查询</button>
								<!-- <button type="button" class="btn btn-primary" (click)="showAddRenewal(addRenewalModal)">添加</button>
								<button type="button" class="btn btn-primary" (click)="showImportModal(weightModal)">导入</button> -->
								<button type="button" class="btn btn-primary" (click)="exportData()">导出</button>
							</div>
							<div class="right top-search">
								<input type="text" [(ngModel)]="searchKey" (change)="tableSearch()" class="search-input"
									placeholder="车牌号、操作人、描述、设备ID">
								<span class="top-search-box">
									<button class="top-search-btn" type="button" (click)="tableSearch()"> <i
											class="fa fa-search"></i></button>
								</span>
							</div>
						</div>
						<div class="table_scroll">
							<table
								class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table">
								<thead>
									<tr>
										<th>设备ID</th>
										<th>车牌号码</th>
										<th>事件类型</th>
										<th>描述</th>
										<th>操作人</th>
										<th>创建时间</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<tr *ngFor="let row of tableData"
										[ngClass]='{selected: activeSelected === row.id }'>
										<td>{{row.deviceId}}</td>
										<td>{{row.carNumber}}</td>
										<td>{{row.typeStr}}</td>
										<td>{{row.description}}</td>
										<td>{{row.userName}}</td>
										<td>{{row.createTime}}</td>
										<td>
											<!-- 重置设备ID 才展示 -->
											<button type="button" *ngIf="row.type && row.type === '0105'"
												(click)="relationRepair(row, relationModal)">关联维修</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div class="table-fix clearfix">
							<paginator [totalRecords]="totalCounts" [rows]="pageSize" [currentPage]="curPage - 1"
								(onPageChange)="paginate($event)">
							</paginator>
							<button type="button" class="btn default refresh_btn" (click)="refresh()"><i
									class="fa fa-refresh"></i></button>
						</div>
					</div>
				</div>
			</div>
		</div>

		<!-- 关联维修 -->
		<div bsModal #relationModal="bs-modal" id="relationModal" class="modal fade" tabindex="-1" role="dialog"
			aria-labelledby="myLargeModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="width: 900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" (click)="cancelRelationModalModal(relationModal)"
							aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title">选择维修记录</h4>
					</div>
					<div class="modal-body" style="padding: 15px 15px 30px 15px">
						<div class="table_scroll">
							<table
								class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table">
								<thead>
									<tr>
										<th>
											<div class="checkbox" style="margin:0;left: 5px;text-align: center;">
												<label>
													<input type="checkbox" class="checkbox style-0" disabled>
													<span></span>
												</label>
											</div>
										</th>
										<th>车牌号码</th>
										<th>设备ID</th>
										<th>所属公司</th>
										<th>维修人员</th>
										<th>维修时间</th>
										<th>故障现象</th>
										<th>维修记录</th>
									</tr>
								</thead>
								<tbody>

									<tr *ngFor="let row of relationTableData">
										<td>
											<div class="checkbox" style="margin:0;left: 5px;text-align: center;">
												<label class="checkbox-label">
													<input type="checkbox" class="checkbox style-0"
														[(ngModel)]="row.isChecked" (click)="rowSelected(row,$event,i)">
													<span class=" checkbox-flag"></span>
												</label>
											</div>
										</td>
										<td>{{row.carNumber}}</td>
										<td>{{row.deviceId}}</td>
										<td>{{row.companyName}}</td>
										<td>{{row.repairedUserName}}</td>
										<td>{{row.repairedTime}}</td>
										<td>
											<span
												*ngIf="row.faultPhenomenonList && row.faultPhenomenonList.length">{{row.faultPhenomenonList.join(",")}}</span>
										</td>
										<td>
											<span
												*ngIf="row.repairContentList && row.repairContentList.length">{{row.repairContentList.join(",")}}</span>
										</td>
									</tr>
								</tbody>
							</table>
							<div *ngIf="rowDetailed && rowDetailed.length">
								<label style="margin: 10px 0;">维修明细</label>
								<table
									class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table">
									<thead>
										<tr>
											<th>维修编号</th>
											<th>维修时间</th>
											<th>故障现象</th>
											<th>维修内容</th>
											<th>维修细分</th>
											<th>故障现象详情</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>

										<tr *ngFor="let row of rowDetailed">
											<td>{{row.repairedNumber}}</td>
											<td>{{row.repairedTime}}</td>
											<td>{{pTypeList[row.pType*1-1]}}</td>
											<td>{{typeList[row.type*1-1]}}</td>
											<td>
												<span
													*ngIf="row.repairContent && row.repairContent.length">{{row.repairContent.join(',')}}</span>
											</td>
											<td>{{row.faultPhenomenon}}</td>
											<td>
												<button type="button" (click)="editRow(row,editModal)"
													*ngIf="editCheck">编辑</button>
											</td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default"
							(click)="notAssociated(relationModal)">未关联</button>
						<button type="button" class="btn btn-default"
							(click)="cancelRelationModalModal(relationModal)">取消</button>
						<button type="button" class="btn btn-primary"
							(click)="cancelRelationSubmit(relationModal)">提交</button>
					</div>
				</div>
			</div>
		</div>
		<!-- 关联维修 end-->

		<!-- 编辑   弹窗-->
		<section bsModal #editModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
			aria-labelledby="myLargeModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-lg">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" (click)="editClose(editModal)" aria-label="Close"><span
								aria-hidden="true">&times;</span></button>
						<h4 class="modal-title">编辑</h4>
					</div>
					<div class="modal-body" style="min-height: 250px;">
						<div class="row form-horizontal">
							<div class="form-group col-xs-12">
								<label class="control-label col-xs-2" style="padding: 7px 0 0;">维修细分<sup>*</sup></label>
								<div class="col-xs-10">
									<div *ngFor="let item of repairContent;let i= index" style="margin-bottom: 10px;">
										<input type="text" class="repairContent col-xs-10" autocomplete="off"
											name="repairContent" [value]="item?item:''" placeholder="请填写维修细分"
											(change)="contentChange($event.target.value,i)" />
										<span class="addBtn" *ngIf="i==0" (click)="addNum(i)"><i class="fa fa-plus"
												aria-hidden="true"></i></span>
										<span class="addBtn" *ngIf="i>0" (click)="reduceNum(i)"><i class="fa fa-minus"
												aria-hidden="true"></i></span>
									</div>

								</div>
							</div>
							<div class="form-group col-xs-12">
								<label class="control-label col-xs-2" style="padding: 7px 0 0;">故障现象<sup>*</sup></label>
								<div class="col-xs-10">
									<div class="clearfix">
										<select class="form-control" name="repairedPType" style="width: 100%"
											[(ngModel)]='repairedPType' (change)="repairedPTypeChange()">
											<option value="1">离线问题</option>
											<option value="2">GPS问题</option>
											<option value="3">传感器问题</option>
											<option value="4">甩挂问题</option>
										</select>
									</div>
								</div>
							</div>
							<div class="form-group col-xs-12">
								<label class="control-label col-xs-2 noPadding"
									style="padding: 7px 0 0;">故障现象详情<sup>*</sup></label>
								<div class="col-xs-10">
									<div class="clearfix">
										<select class="form-control" name="faultPhenomenon" style="width: 100%"
											[(ngModel)]='faultPhenomenon'>
											<option *ngFor="let item of faultPhenomenonList" [value]="item.value">
												{{item.label}}</option>
										</select>
									</div>
								</div>
							</div>
							<div class="form-group col-xs-12">
								<label class="control-label col-xs-2" style="padding: 7px 0 0;">维修内容<sup>*</sup></label>
								<div class="col-xs-10">
									<div class="clearfix">
										<select class="form-control" name="repairedType" style="width: 100%"
											[(ngModel)]='repairedType'>
											<option value="1">更换主机</option>
											<option value="2">电源维修</option>
											<option value="3">更换线材</option>
											<option value="4">挪动天线位置</option>
											<option value="5">更换天线</option>
											<option value="6">V4换V7</option>
											<option value="7">更换传感器</option>
											<option value="8">重新焊接</option>
											<option value="9">离线其他</option>
											<option value="10">GPS其他</option>
											<option value="11">传感器其他</option>
											<option value="12">无维修</option>
										</select>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" (click)="editClose(editModal)">取消</button>
						<button type="button" class="btn btn-primary" (click)="editSubmit(editModal)">提交</button>
					</div>
				</div>
			</div>
		</section>
		<!-- 编辑 弹窗end-->
	</sa-widgets-grid>
</div>